﻿namespace IntegrationTests.QueryToSQLTests
{
    using System;
    using DirectoryServicesProtocolsExtensions.SearchRequest;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
   
    [TestClass]
    public class QueryToSqlTableSchemaTests : LdapTest
    {
        [TestMethod]
        public void BuildTamplateDataTableTest()
        {
            var ldapQueryPropertiesContainer = new MockFabrikamActiveDirectoryQueryPropertiesContainer
            {
                SearchBaseDN = "CN=Administrator,CN=Users,DC=fabrikam,DC=com",
                AttributesToLoad = new[] { "distinguishedname", "objectGUID", "memberof" }
            };

            var pagedSearchRequest = new PagedSearchRequest(ldapQueryPropertiesContainer);
            var resultingTable = pagedSearchRequest.BuildDataTableToHoldResults(LdapConnection, LdapMetaMapFactory);
            Assert.AreEqual(resultingTable.Columns.Count, pagedSearchRequest.Attributes.Count);
            Assert.AreEqual(resultingTable.Columns["objectGUID"].DataType, typeof(Guid));
            Assert.AreEqual(resultingTable.Columns["memberof"].DataType, typeof(string));
        }
    }
}
